package huy.mmt.gamelathinh.dialog;

import huy.mmt.gamelathinh.Main;
import huy.mmt.gamelathinh.Play;
import huy.mmt.gamelathinh.R;
import huy.mmt.gamelathinh.util.Util;
import huy.mmt.gamelathinh.util.UtilDialog;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

/**
 * Hiá»‡n thá»‹ khi ngÆ°á»�i dÃ¹ng chá»�n tráº¡ng thÃ¡i táº¡m dá»«ng game. Sau
 * khi táº¡m dá»«ng game thÃ¬ ngÆ°á»�i chÆ¡i cÃ³ thá»ƒ chá»�n cÃ¡c chá»©c nÄƒng:
 * 
 * + Reset: ChÆ¡i láº¡i level hiá»‡n táº¡i + Setting: VÃ o pháº§n cÃ i Ä‘áº·t +
 * Menu: Quay láº¡i menu chÃ­nh + Continue: Tiáº¿p tá»¥c chÆ¡i
 * 
 * @author Huy
 * 
 */
public class DialogPause extends Dialog implements
		android.view.View.OnClickListener {
	Activity activity;

	public DialogPause(Context context) {
		super(context);
		UtilDialog.iniDialog(this);
		activity = (Activity) context;

		setContentView(R.layout.dialog_pause);

		// resize dialog
		LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearlayout_all);
		Util.resizeDialog(linearLayout);
		Button button_continue = (Button) findViewById(R.id.button_continue);
		button_continue.setOnClickListener(this);

		Button button_refresh = (Button) findViewById(R.id.button_refresh);
		button_refresh.setOnClickListener(this);

		Button button_setting = (Button) findViewById(R.id.button_setting);
		button_setting.setOnClickListener(this);

		Button button_level = (Button) findViewById(R.id.button_menu);
		button_level.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {

		Main.click.start();

		switch (v.getId()) {
		case R.id.button_continue:
			this.dismiss();
			Play.resumeTimerout();
			break;
		case R.id.button_refresh:
			this.dismiss();
			Play.countDownTimer.cancel();
			Play.newGame(Play.difficutly.getX(), Play.difficutly.getY());
			// Play.mPlay.resetGame();

			break;
		case R.id.button_setting:
			showDialogSetting();
			break;
		case R.id.button_menu:
			this.dismiss();
			Play.mPlay.finish();

			break;
		default:
			break;
		}
	}

	/**
	 * Hiá»‡n thá»‹ dialog setting
	 */
	public void showDialogSetting() {
		DialogSetting mDialogSetting = new DialogSetting(activity);
		mDialogSetting.show();
	}
}